//
//  ViewController.m
//  runtime字典Model
//
//  Created by webplus on 17/9/1.
//  Copyright © 2017年 sanyi. All rights reserved.
//

#import "ViewController.h"
#import "TestModel.h"

@interface ViewController ()
@property (nonatomic,assign) BOOL isOn;
@property (nonatomic,strong) TestModel *model;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    if (self.isOn) {
        NSDictionary *dict2 = [_model convertToDictionary];
        NSLog(@"*****%@",dict2);
        _isOn = NO;
    }else{
        NSDictionary *dict1 = @{@"name":@"小王",@"age":@"22",@"sex":@"男",@"address":@"河南"};
        _model = [[TestModel alloc]initWithDictionary:dict1];
        NSLog(@"%@---%@",_model.name,_model.age);
        _isOn = YES;
    }
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
